<template>
    <!-- 使用简单的确认对话框样式，不需要复杂的表单逻辑 -->
    <a-modal ref="modalRef" v-model:open="open" title="删除Oem" @ok="handleOk" @cancel="onCancel" :closable="false">
        <p>确定删除Oem吗?</p>
    </a-modal>
</template>
<script setup lang="ts">
    import { ref } from 'vue';
    import { message } from 'ant-design-vue';
    import { bizApi } from '@/api/biz'; // 导入API模块

    const open = ref<boolean>(false);
    const modalRef = ref(); //通用模态弹窗组件引用
    const editId = ref(0); //要修改的记录ID
    const emits = defineEmits<{ dataReload: [] }>(); //通知调用组件执行@dataReload方法

    /* [显示弹窗] */
    function show(id: number) {
        editId.value = id;
        open.value = true;
    }

    defineExpose({ show }); //暴露show方法供父组件调用

    /* [关闭弹窗] */
    function onCancel() {
        open.value = false;
    }

    /* [确认删除] */
    const handleOk = async () => {
        const deleteParams = { oem_id: editId.value };
        try {
            open.value = false;            
            const result = await bizApi.httpSave(deleteAction, deleteParams);
            message.success('删除成功');
            emits('dataReload');
        } catch (error: any) {
            console.error('删除失败:', error);
            message.error('删除操作处理异常');
        }
    };

    const deleteAction = 'base.agent.oem.ServiceImpl.delete'; //delete接口方法名
</script>

<style lang="less" scoped></style>